package base

/*
* @author: hjz
* @time: 2025/4/26 17:57
* @ 借助hash表,每次判断数据是否已经存在
 */
func twoSum(nums []int, target int) []int {
	m := make(map[int]int, len(nums))
	for i, num := range nums {
		if j, ok := m[target-num]; ok {
			return []int{i, j}
		}
		m[num] = i
	}
	return nil
}
